package com.venueproject.mapper;

import com.venueproject.pojo.Appoiment;
import com.venueproject.pojo.Venue;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface AppoimentMapper {


    //查询总记录数
    Long count(@Param("number") String number, @Param("name") String name);
    //分页查询
    List<Venue> page(@Param("start") Integer start, @Param("pageSize") Integer pageSize, @Param("number") String number, @Param("name") String name);


    //预约信息查询
    @Select("select number,name,date from appoiment")
    List<Appoiment>getAppoiment();

    //判断场地当日是否可以预约
    @Select("select * from appoiment where number = #{number} and date = #{dateTime}")
    Appoiment selectAppoiment(@Param("number") String number, @Param("dateTime") LocalDate dateTime);


    //插入预约信息
    @Insert("insert into appoiment(number,name,date) values(#{number},#{name},#{date})")
    void insertAppoiment(Appoiment appoiment);


    //预约人数加1
    @Update("update venue set count=count+1 where id = #{id}")
    void Addappoiment(@Param("id") int id);
}
